; https://en.wikipedia.org/wiki/INT_13H
disk_load:
    pusha
    ; reading from disk requires setting specific values in all registers
    ; so we will overwrite our input parameters from 'dx'. Let's save it
    ; to the stack for later use.
    push dx

    mov ah, 0x02 ;BIOS read sector function
    mov al, dh ; readh dh numbers of sector
    mov ch, 0x00; select cylinder 0
    mov dh, 0x00; select head 0
    mov cl, 0x02 ; start reading from second sector

    int 0x13 ;bios interrupt

    jc disk_error ; jump if CF set

    pop dx
    cmp dh, al ; bios will set al how many sectors really read
    jne disk_error

    mov bx, DISK_SUCCESS_MSG
    call print_str
    call print_nl

    popa
    ret

disk_error:
    mov bx, DISK_ERROR_MSG
    call print_str
    call print_nl

    mov bx, DISK_ERROR_MSG1
    call print_str
    mov dx, ax
    and dx, 0x00ff
    call print_hex
    call print_nl

    mov bx, DISK_ERROR_MSG2
    call print_str
    mov dx, ax
    shr dx, 0x08
    call print_hex
    call print_nl

    jmp $

DISK_SUCCESS_MSG:
    db "Disk read success", 0

DISK_ERROR_MSG:
    db  "Disk read error", 0
DISK_ERROR_MSG1:
    db "Number of sectors read: ", 0

DISK_ERROR_MSG2:
    db "Disk Read Error Code: ", 0
